package com.jxd.project.report.controller;

import com.jxd.project.absence.model.Dept;
import com.jxd.project.absence.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName DeptController
 * @Description TODO
 * @Author 孙福桐
 * @Date 2025/10/1 18:29
 * @Version 1.0
 */
@RestController
public class DeptController {
    @Autowired
    private IDeptService deptService;

    /**
     * 修改部门
     * @param dept
     * @return
     */
    @RequestMapping("/editDept")
    public String editDept(@RequestBody Dept dept){
        if (deptService.updateById(dept)) return "success";
        else return "fail";
    }

    @RequestMapping("/addDept")
    public String addDept(@RequestBody Dept dept){
        if (deptService.addDept(dept)) return "success";
        else return "fail";
    }

    /**
     * 获取部门
     * @param queryMap
     * @return
     */
    @RequestMapping("/getDept")
    public Map<String,Object> getDept(@RequestBody Map<String,String> queryMap){
        return deptService.getDept(queryMap);
    }

    /**
     * 删除部门
     * @param deptnos
     * @return
     */
    @RequestMapping("/deleteDept")
    public String deleteDept(@RequestBody List<Integer> deptnos){
        if (deptService.deltetDept(deptnos)) return "success";
        else return "fail";
    }
}
